"""
Description:
Author: 月间
Date: 2024-08-13 20:28:45
LastEditTime: 2025-03-23 19:50:42
LastEditors:
"""

# @Version        : 1.0
# @Update Time    : 2024/7/10 21:17
# @File           : m2m.py
# @IDE            : PyCharm
# @Desc           : 文件描述信息
from advanced_alchemy.base import orm_registry
from sqlalchemy import ForeignKey, Column, Table, BigInteger

# 用户角色关系表
sys_user_role = Table(
    "sys_user_role",
    orm_registry.metadata,
    Column(
        "user_id",
        BigInteger,
        ForeignKey("sys_user.id", ondelete="CASCADE"),
        primary_key=True,
    ),
    Column(
        "role_id",
        BigInteger,
        ForeignKey("sys_role.id", ondelete="CASCADE"),
        primary_key=True,
    ),
)

sys_role_menu = Table(
    "sys_role_menu",
    orm_registry.metadata,
    Column(
        "role_id",
        BigInteger,
        ForeignKey("sys_role.id", ondelete="CASCADE"),
        primary_key=True,
    ),
    Column(
        "menu_id",
        BigInteger,
        ForeignKey("sys_menu.id", ondelete="CASCADE"),
        primary_key=True,
    ),
)

sys_user_post = Table(
    "sys_user_post",
    orm_registry.metadata,
    Column(
        "user_id",
        BigInteger,
        ForeignKey("sys_user.id", ondelete="CASCADE"),
        primary_key=True,
    ),
    Column(
        "post_id",
        BigInteger,
        ForeignKey("sys_post.id", ondelete="CASCADE"),
        primary_key=True,
    ),
)

sys_role_dept = Table(
    "sys_role_dept",
    orm_registry.metadata,
    Column(
        "role_id",
        BigInteger,
        ForeignKey("sys_role.id", ondelete="CASCADE"),
        primary_key=True,
    ),
    Column(
        "dept_id",
        BigInteger,
        ForeignKey("sys_dept.id", ondelete="CASCADE"),
        primary_key=True,
    ),
)
